package com.dody.junit;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author ShiXin
 * @date 2019/4/19 21:11
 * @description lite-junit
 */
public abstract class TestCase extends Assert implements Test {

    private String name;

    public TestCase(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        setUp();
        try {
            runTest();
        } catch (Exception e) {

        }finally {
            tearDown();
        }
    }

    protected void runTest() throws Exception {
        Method method = getClass().getMethod(name, null);
        method.invoke(this, null);
    }

    protected void setUp(){}

    protected void tearDown(){}

    public static void main(String[] args) {

    }
}
